home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 2
/
Gold Medal Software Volume 2 (Gold Medal) (1994).iso
/
prog
/
pclcjs.arj
/
TIMECHK.C
< prev
Wrap
Text File
|
1993-05-23
|
674b
|
24 lines
/* function check_time
Accepts a time in the format HH:MM and determines its validity
Returns:
0 if valid
nonzero if invalid
*/
int check_time(char *this_time)
{
if (this_time[2] != ':')
return(2);
if ((this_time[0] < '0') || (this_time[0] > '2'))
return(3);
if ((this_time[0] == '0' && (this_time[1] < '0' || this_time[1] > '9')) || ((this_time[0] == '2') && (this_time[1] < '0' || this_time[1] > '3')))
return(4);
if (this_time[3] < '0' || this_time[3] > '5')
return(5);
if (this_time[4] < '0' || this_time[4] > '9')
return(6);
return(0);
}